#codon gcc version does not support -std=c90, using -ansi
#BUILD_FLAGS := -std=c90 -O0 -pipe
BUILD_FLAGS := -ansi -O0 -pipe
WARNING_FLAGS := -Wall -Wextra -Wconversion -Werror -pedantic-errors

BUILD_DIR := ../build
OBJS := $(addprefix $(BUILD_DIR)/, spacer.o read.o)
OUTPUT_DIR := ../bin
BIN_NAME := spacer

build: $(OBJS)
	gcc -o $(OUTPUT_DIR)/$(BIN_NAME) $(OBJS)

$(BUILD_DIR)/spacer.o: spacer.c
	gcc -x c -c -o $(BUILD_DIR)/spacer.o $(BUILD_FLAGS) $(WARNING_FLAGS) spacer.c

$(BUILD_DIR)/read.o: read.c
	gcc -x c -c -o $(BUILD_DIR)/read.o $(BUILD_FLAGS) $(WARNING_FLAGS) read.c

$(OBJS): | $(BUILD_DIR) $(OUTPUT_DIR)

$(BUILD_DIR):
	mkdir $(BUILD_DIR)

$(OUTPUT_DIR):
	mkdir $(OUTPUT_DIR)

.PHONY clean:
	rm -rf $(BUILD_DIR) $(OUTPUT_DIR)
